/*
 * Copyright (c) 2009. Silenus Consultoria, S.L.
 */
package es.silenus.detecta.model;

/**
 * Group of locations in a given province. This is a read-only persistent class.
 *
 * @author <a href="mailto:malonso@silenus-consultoria.es">Mariano Alonso</a>
 *
 * @since 22-mar-2009 11:04:04
 */
public class Council implements java.io.Serializable {
	/**
	 * The identifier.
	 */
	private String id;

	/**
	 * The INE code.
	 */
	private String code;

	/**
	 * The council name.
	 */
	private String name;

	/**
	 * The council province.
	 */
	private Province province;

/**
   * Constructor.
   */
	public Council() {
	}

	/**
	 * Retrieves the identifier.
	 *
	 * @return the identifier.
	 */
	public String getId() {
		return this.id;
	}

	/**
	 * Sets the identifier.
	 *
	 * @param id the identifier.
	 */
	public void setId(final String id) {
		this.id = id;
	}

	/**
	 * Retrieves the code.
	 *
	 * @return the code.
	 */
	public String getCode() {
		return code;
	}

	/**
	 * Sets the code.
	 *
	 * @param code the code.
	 */
	public void setCode(final String code) {
		this.code = code;
	}

	/**
	 * Retrieves the name.
	 *
	 * @return the name.
	 */
	public String getName() {
		return this.name;
	}

	/**
	 * Sets the name.
	 *
	 * @param name the name.
	 */
	public void setName(final String name) {
		this.name = name;
	}

	/**
	 * Retrieves the province.
	 *
	 * @return the province.
	 */
	public Province getProvince() {
		return this.province;
	}

	/**
	 * Sets the province.
	 *
	 * @param province the province.
	 */
	public void setProvince(final Province province) {
		this.province = province;
	}

	/**
	 * Checks if objects are equal.
	 *
	 * @param o other object.
	 *
	 * @return true if equal, false otherwise.
	 */
	@Override
	public boolean equals(Object o) {
		if(this == o) {
			return true;
		}

		if(!(o instanceof Council)) {
			return false;
		}

		Council council = (Council)o;

		if((getId() != null) ? (!getId().equals(council.getId())) : (council.getId() != null)) {
			return false;
		}

		return true;
	}

	/**
	 * Calculates the hash of this instance.
	 *
	 * @return the hash code.
	 */
	@Override
	public int hashCode() {
		return (getId() != null) ? getId().hashCode() : 0;
	}

	/**
	 * Stringifies this instance.
	 *
	 * @return the string representation.
	 */
	@Override
	public String toString() {
		final StringBuilder sb = new StringBuilder();

		sb.append("Council");
		sb.append("{id='").append(getId()).append('\'');
		sb.append(", name='").append(getName()).append('\'');
		sb.append('}');

		return sb.toString();
	}
}
